﻿@{
    Layout = null;
}

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="ModifyPwdPage">
<head>
    <title>修改密码</title>
    <meta name="viewport" content="width=device-width" />
    <link href="@Href("~/Scripts/jquery-easyui-1.4/themes/default/easyui.css")" rel="stylesheet"
          type="text/css" />
    <link href="@Href("~/Scripts/jquery-easyui-1.4/themes/icon.css")" rel="stylesheet" type="text/css" />
    <script src="@Href("~/Scripts/jquery-easyui-1.4/jquery-1.8.0.min.js")" type="text/javascript"></script>
    <script src="@Href("~/Scripts/jquery-easyui-1.4/jquery.easyui.min.js")" type="text/javascript"></script>
    <script src="@Href("~/Scripts/jquery-easyui-1.4/locale/easyui-lang-zh_CN.js")" type="text/javascript"></script>
    <script src="@Href("~/Scripts/jquery-easyui-1.4/easyui-validate.js")" type="text/javascript"></script>
    <script src="@Href("~/Scripts/angularjs/angular.js")" type="text/javascript"></script>
    <script type="text/javascript">

        angular.module('ModifyPwdPage', [])
            .controller('ModifyPwdController', ['$http', function ($http) {
                var ModifyBean = this;
                ModifyBean.bean = { name: '@Session["LoginedUser"].ToString()', loginname: '@Session["LoginedUser"].ToString()',oldPwd:'',newPwd:'',newPwd2:'' };
                //修改密码
                ModifyBean.modify = function () {
                    if (ModifyBean.bean.oldPwd.length == 0 || ModifyBean.bean.newPwd.length == 0 || ModifyBean.bean.newPwd2.length == 0) {
                        $.messager.show({ title: "提示", msg: "输入框不能为空" });
                        return false;
                    }
                    if (ModifyBean.bean.newPwd != ModifyBean.bean.newPwd2) {
                        $.messager.show({ title: "提示", msg: "新密码两次输入不一致" });
                        angular.element('#newPwd').focus();
                        ModifyBean.bean.newPwd = ModifyBean.bean.newPwd2 = "";
                        return false;
                    }

                    $http.post('/Home/ModifyPwd/', ModifyBean.bean)
                        .success(function (data, status, headers, config) {
                            if (data.error) {
                                $.messager.show({ title: "提示", msg: data.msg });
                            } else {
                                alert("修改成功");
                                top.window.location.replace("/Home/Login");
                            }
                        })
                        .error(function (data, status, headers, config) {
                            alert(data.msg);
                        });
                };
                //取消
                ModifyBean.cancel = function () {
                    ModifyBean.bean.newPwd = ModifyBean.bean.newPwd2 = ModifyBean.bean.oldPwd = "";
                    angular.element('#oldPwd').focus()
                };
            }]);
    </script>
    <style type="text/css">
        body {
            margin: 1px !important;
            padding: 0;
        }

        .content {
            width: 400px;
            margin: 100px auto;
        }
    </style>
</head>
<body ng-controller="ModifyPwdController as ModifyPwd">
    <div class="content">
        <div id="p" class="easyui-panel" data-options="iconCls:'icon-user'" title="用户信息"
             style="width: 100%; height: 290px;">
            <div style="padding: 10px 60px 20px 60px">
                <table cellpadding="5">
                    <tr>
                        <td>
                            用&nbsp;&nbsp;&nbsp;&nbsp;户&nbsp;&nbsp;&nbsp;&nbsp;名:
                        </td>
                        <td>
                            <input type="text" id="name" name="name" readonly="readonly" ng-model="ModifyPwd.bean.name" style="width:155px;" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;&nbsp;&nbsp;&nbsp;名:
                        </td>
                        <td>
                            <input type="text" id="loginname" name="loginname" readonly="readonly" ng-model="ModifyPwd.bean.loginname" style="width:155px;" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            原&nbsp;&nbsp;&nbsp;&nbsp;密&nbsp;&nbsp;&nbsp;&nbsp;码:
                        </td>
                        <td>
                            <input type="password" id="oldPwd" name="oldPwd" style="width:155px;" ng-model="ModifyPwd.bean.oldPwd" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            新&nbsp;&nbsp;&nbsp;&nbsp;密&nbsp;&nbsp;&nbsp;&nbsp;码:
                        </td>
                        <td>
                            <input type="password" id="newPwd" name="newPwd" style="width:155px;" ng-model="ModifyPwd.bean.newPwd" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            确认新密码:
                        </td>
                        <td>
                            <input type="password" id="newPwd2" name="newPwd2" style="width:155px;" ng-model="ModifyPwd.bean.newPwd2" />
                        </td>
                    </tr>
                </table>
                <div style="text-align: center; padding: 5px">
                    <a href="javascript:void(0)" data-options="iconCls:'icon-ok'" class="easyui-linkbutton" ng-click="ModifyPwd.modify()">修 改</a>
                    <a href="javascript:void(0)" data-options="iconCls:'icon-cancel'" class="easyui-linkbutton" ng-click="ModifyPwd.cancel()">清 空</a>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
